#include <iostream>
#include <cstring>
#include <algorithm>
#define int long long

using namespace std;
const int N = 2 * 1e5 + 10;
int a[N],n;
int T;
int ans = 0;

void check(int c[])
{
    int num = 0;
    for (int i = 1;i <= n;i ++)
    {
        for (int j = i - 1;j > 0;j --)
        {
            if (a[i] == a[j] && c[i] == c[j])
            {
                num += a[i];
                break;
            }
        }
    }
    ans = max(ans,num);
}

void dfs(int idx,int c[])
{
    if (idx == n + 1)
    {
        check(c);
        return;
    }
    c[idx] = 1;
    dfs(idx + 1,c);
    c[idx] = 2;
    dfs(idx + 1,c);

}

signed main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin >> T;
    while (T --)
    {
        ans = 0;
        cin >> n;
        for (int i = 1;i <= n;i ++) cin >> a[i];
        int c[N];
        dfs(1,c);
        cout << ans << endl;
    }
    return 0;
}
